package com.lo.controller;

import com.lo.common.JsonResult;
import com.lo.entity.Comment;
import com.lo.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("comment")
public class CommentController {
    @Autowired
    private CommentService commentService;

    @RequestMapping("selectCourseComments/{cid}")
    public JsonResult selectCourseComments(@PathVariable Long cid){
        JsonResult result = commentService.selectCourseComments(cid);
        return result;
    }

    @RequestMapping("addComment")
    public JsonResult addComment(Comment comment){
        JsonResult result = commentService.addComment(comment);
        return result;
    }

    @RequestMapping("deleteComment")
    public JsonResult deleteComment(@RequestBody Comment comment){
        return commentService.deleteComment(comment);
    }


    @RequestMapping("selectTextComments")
    public JsonResult selectTextComments(Long id){
        return commentService.selectTextComments(id);
    }
}
